#include "Mutex.h"

namespace Core
{
	rtMutex::rtMutex(void)
	{
		InitializeCriticalSection(&m_CS);
	}


	rtMutex::~rtMutex(void)
	{
		DeleteCriticalSection(&m_CS);
	}

	bool rtMutex::lock(bool blocking)
	{
		if(TryEnterCriticalSection(&m_CS) == 0)
		{
			if(blocking == false)
			{
				return false;
			}

			EnterCriticalSection(&m_CS);
		}
		return true;
	}

	void rtMutex::unlock()
	{
		LeaveCriticalSection(&m_CS);
	}


	rtMutex::rtMutex(const rtMutex& m) 
	{

	}

	rtMutex& rtMutex::operator = (const rtMutex& m) 
	{
		return *(this);
	}
}

